//
//  IObject.h
//  bird
//
//  Created by Xiaochen Lian on 5/2/12.
//  Copyright (c) 2012 University of California, Los Angeles. All rights reserved.
//

#ifndef bird_object_h
#define bird_object_h

#include <vector>
#include "common.h"

enum PART_TYPE {ROOT, BODY, SHOULDER, FOREARM, WRIST, FEATHER};

class IEntity {

public:
    IEntity();
    ~IEntity();
    
    virtual PART_TYPE get_type();
    void set_type(PART_TYPE type);
    virtual void set_pos(const point4 &pos);
    point4 get_pos();
    point4 get_mass_center();
    virtual bool is_right();
    
    virtual void build_model(const point4 &parent_mass_center) = 0;
    virtual void add_child(IEntity *part);
    
    virtual void draw(const mat4 &tfm_parent) = 0;    
    virtual void draw_axis(const mat4 &tfm_parent);
    
    virtual vec4 aerodynamics(const bird_status &nstatus, const mat4 &tfm, const double timestep);
    virtual void update(const bird_status &cstatus, const mat4 tfm_parent);
    virtual void init(const bird_status &cstatus) = 0;
    
protected:
    virtual mat4 tfm_from_status(const bird_status &nstatus);
    
protected:
    bool m_visible;
    PART_TYPE m_type;
    point4 m_model_pos;
    point4 m_mass_center;
    mat4 m_model_mat, m_tfm, m_scale_mat, m_next_tfm;
    ShapeData m_shape_data;
    
    std::vector<IEntity*> m_children; 
    IEntity *parent;
};

#endif
